package com.powerteam.controller.masterData;

import com.powerteam.model.masterData.District;
import com.powerteam.service.masterData.DistrictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 地区信息相关接口
 *
 * @author jinming.zhang
 * @version 0.0.1
 * @date 2021/12/30
 */
@Slf4j
@Controller
@RequestMapping("/district")
public class DistrictController {

    @Autowired
    private DistrictService districtService;

    /**
     * 查找所有省份
     *
     * @param
     * @return List<District>
     * @Author jinming.zhang
     * @Date 2022/1/10
     */
    @ResponseBody
    @RequestMapping(value = "/findAllProvince", method = RequestMethod.POST)
    public List<District> findAllProvince() {

        return districtService.findArea(null);
    }

    /**
     * 查找所有城市
     *
     * @param provinceId
     * @return List<District>
     * @Author jinming.zhang
     * @Date 2022/1/10
     */
    @ResponseBody
    @RequestMapping(value = "/findCity", method = RequestMethod.POST)
    public List<District> findCity(@RequestBody Integer provinceId) {

        return districtService.findArea(provinceId);
    }

    /**
     * 查找所有县
     *
     * @param cityId
     * @return List<District>
     * @Author jinming.zhang
     * @Date 2022/1/10
     */
    @ResponseBody
    @RequestMapping(value = "/findCounty", method = RequestMethod.POST)
    public List<District> findCounty(@RequestBody Integer cityId) {

        return districtService.findArea(cityId);
    }

}
